;
(function() {
    // @mouseenter="addbgcolor($event, index0)"
    // @mouseleave="removebgcolor"
    Vue.component('tree-privilege', {
        template: `<div>
    <li v-for="(item0, index0) in model" class="userframework-tree-list" :class="{slideTopActive: showList.indexOf(item0.id) > -1,userpaddingLeft: item0.level < 5}" >
      <div
        class="userframework-title clearfix cursor"
        ref="c1"
        @click.stop.prevent="toggle(index0, item0, $event)"
        @mouseenter="addbgcolor($event, item0)"
        @mouseleave="hidehandle($event, item0)"
        :data-id="item0.id"
        :data-parentId="item0.parentId"
        :data-type="item0.type"
        :data-index="index0">
        <div class="pull-left z-50 relative">
          <div v-if="showEdit != item0.id" class="ellipsis-1" style="width:125px" :title="item0.shortName">
            <span class="staff" v-if="item0.orgType == 'DD' && item0.orgMemberType == 'STAFF' && item0.level == '2' ">员工</span>
            <span class="usercustomer"  v-if="item0.orgType == 'DD' && item0.orgMemberType == 'CUSTOMER' && item0.level == '2' ">客户</span>
          {{item0.shortName}}</div>
        </div>
        <ul class="icon--- arrowIcon_item color-999" :class="{'icon-reg-90': showList.indexOf(item0.id) > -1}"  ></ul>
        <div class="border-b tissue-border"></div>

      </div>

      <ul v-if="showList.indexOf(item0.id) > -1">
        <tree-privilege
          class="item"
          :key="index0"
          @change="getPidData"
          @getdata="getdata"
          ref="c1"
          :model="item0.children">
        </tree-privilege>
      </ul>
    </li>

    </div>`,
        props: {
            model: [Object, Array],
            num: [String]
        },
        data: function() {
            return {
                index: 0,
                data: [],
                showInput: '',
                editshortName: '',
                showEdit: '',
                inputType: '',
                showList: [],
                permissions: JSON.parse(window.localStorage.getItem('permissions')),
            }
        },
        methods: {
            //点击展开并且调用下级菜单
            toggle: function(i, data, e, t, s) {
                this.getdata(data)

                if (this.showList.indexOf(data.id) == -1) {
                    this.showList.push(data.id)
                } else {
                    this.showList.splice(this.showList.indexOf(data.id), 1)
                }
                this.getPidData(data.id)
            },
            getPidData(id, type, localId) {
                if (type && localId) {
                    this.$emit('change', id, type, localId)
                    return
                }
                this.$emit('change', id)
            },
            //传给父组件的组织信息
            getdata(data) {
                this.$emit('getdata', data)
            },

           

            //背景色
            addbgcolor(e, data) {
                if (data.orgType == "WX" || data.orgType == "DD") {
                    if (data.id) {
                        e.srcElement.children[2].style.display = 'block'
                    }
                }
            },
            //隐藏
            hidehandle(e, data) {
                if (data.oflag || !data.id || data.orgType == 'DD') return
                e.srcElement.children[2].style.display = 'none'
            },


        },
        mounted() {

        }
    })
}())

// v-if=" item0.orgType == 'WX' "
